package com.weixin.util.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

import java.io.IOException;
import java.util.Date;

/**
 * @author CJunGod
 * @create 2020-03-02 15:10
 **/
public class Date2LongSerializer extends JsonSerializer<Date> {

    public void serialize(Date date, JsonGenerator jsonGenerator, SerializerProvider SerializerProvider) throws IOException {

        jsonGenerator.writeNumber(date.getTime() / 1000);
    }
}
